﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ex02
{
    class Program
    {
        static void Main(string[] args)
        {
            var db = new NorthwindDataContext();
            // Look at the SQL results pane - only one SQL statement is generated as LINQPad
            // enumerates the results of this query.
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            var query = (from c in db.Customers
                select
                from p in c.Purchases
                select new { c.Name, p.Price }
            );
            foreach (var entry in query)
            {
                foreach (var q in entry)
                {
                    Console.WriteLine("{0},{1}",q.Name,q.Price);
                }
                Console.WriteLine();
            }
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            Console.ReadKey();
        }
    }
}
